//
//  BaseTabBarViewController.m
//  WDMusicPlayer
//
//  Created by lanou3g on 15/6/25.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "BaseTabBarViewController.h"

#import "MineViewController.h"

@interface BaseTabBarViewController ()<UITabBarControllerDelegate>
@property(nonatomic,strong)ScoreViewController*scoreVC;

@end

@implementation BaseTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    LiveViewController *liveVC = [[LiveViewController alloc] init];
    VideoViewController *videoVC = [[VideoViewController alloc] init];
    
    ScoreViewController *scoreVC = [[ScoreViewController alloc] init];
    self.scoreVC = scoreVC;
    
    
    DataSportsViewController * leftSideDrawerViewController = [[DataSportsViewController alloc] init];
    DataViewController * centerViewController = [DataViewController shareInstance];
    
    
    // 设置资料界面抽屉
    MMDrawerController * drawerController = [[MMDrawerController alloc]
                                             initWithCenterViewController:centerViewController leftDrawerViewController:leftSideDrawerViewController];
//    // 设置抽屉抽出的宽度
    [drawerController setMaximumLeftDrawerWidth:kScreenIp6(100.0)];
//    // 滑动手势开关抽屉
    
    [drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
    [drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
    // 如果设置为以下，则中间左边视图出现后还可以操作中间视图
    drawerController.centerHiddenInteractionMode = MMDrawerOpenCenterInteractionModeNone;
    
   
    
    
    
    [self addChildViewController:liveVC image:[UIImage imageNamed:@"menu_live@2x"] title:@"直播"];
    [self addChildViewController:videoVC image:[UIImage imageNamed:@"menu_resource@2x"] title:@"视频"];
    [self addChildViewController:scoreVC image:[UIImage imageNamed:@"menu_sport@2x"] title:@"比分"];
    [self addChildViewController:drawerController image:[UIImage imageNamed:@"menu_feedback@2x"] title:@"资料"];
    
     self.delegate = self;
    // tabbar颜色 用于更改字体颜色
    [self.tabBar setTintColor:[UIColor colorWithRed:0.259 green:0.625 blue:0.151 alpha:1.000]];
    
   
    
    
}

- (void)addChildViewController:(UIViewController *)childController image:(UIImage *)image title:(NSString *)title
{
    childController.tabBarItem.image = image;
    childController.tabBarItem.title = title;
    
    childController.title = title;
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:childController];
    [self addChildViewController:nav];
}




- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    
    
    
    NSLog(@"---viewController----%@",viewController);
    
    
    if (tabBarController.selectedIndex ==2)
    {
   
        
           [self.scoreVC addTimes];
        
        
        
    }else
    {
        [self.scoreVC removeTime];

        
    }
    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
